using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace WebOS.Core.Security.Models
{
	public class UserMap : EntityTypeConfiguration<User>
	{
		public UserMap()
		{
			// Primary Key
			this.HasKey(t => t.UserId);

			// Properties
			this.Property(t => t.UserName)
				.IsRequired()
				.HasMaxLength(256);
				
			this.Property(t => t.Password)
				.IsRequired()
				.HasMaxLength(256);
				
			this.Property(t => t.Email)
				.HasMaxLength(256);
				
			this.Property(t => t.PasswordQuestion)
				.HasMaxLength(256);
				
			this.Property(t => t.PasswordAnswer)
				.HasMaxLength(256);
				
			// Table & Column Mappings
			this.ToTable("User");
			this.Property(t => t.UserId).HasColumnName("UserId");
			this.Property(t => t.UserName).HasColumnName("UserName");
			this.Property(t => t.Password).HasColumnName("Password");
			this.Property(t => t.Email).HasColumnName("Email");
			this.Property(t => t.PasswordQuestion).HasColumnName("PasswordQuestion");
			this.Property(t => t.PasswordAnswer).HasColumnName("PasswordAnswer");
			this.Property(t => t.IsValided).HasColumnName("IsValided");
			this.Property(t => t.IsLockedOut).HasColumnName("IsLockedOut");
			this.Property(t => t.CreateDate).HasColumnName("CreateDate");
			this.Property(t => t.LastLoginDate).HasColumnName("LastLoginDate");
			this.Property(t => t.LastPasswordChangeDate).HasColumnName("LastPasswordChangeDate");
			this.Property(t => t.LastLockoutDate).HasColumnName("LastLockoutDate");
			this.Property(t => t.FailedPasswordAttemptCount).HasColumnName("FailedPasswordAttemptCount");
			this.Property(t => t.LastActivityDate).HasColumnName("LastActivityDate");
		}
	}
}

